package gfx;

import java.awt.*;
import java.util.ArrayList;
import javax.swing.JPanel;

import env.Obj;
import static sim.Sim.*;

public class DrawPanel extends JPanel {
	private static final long serialVersionUID = 3000839399227895892L;
	private ArrayList<Drawable> background;

	public DrawPanel() {
		setSize(screenWidth, screenHeight);
		background = new ArrayList<Drawable>();
	}

	public void addBackground(Drawable obj) {
		background.add(obj);
	}

	public void drawObjects(ArrayList<Obj> a) {
		Graphics g = getGraphics();
		g.setColor(Color.WHITE);
		g.setFont(new Font("Monospaced", Font.BOLD, 22));
		g.fillRect(0, 0, screenWidth, screenHeight);

		for (Drawable bObj : background)
			bObj.draw(g);

		for (Obj obj : a)
			if (!(obj instanceof Robot))
				obj.draw(g);

		for (Obj obj : a)
			if (obj instanceof Robot)
				obj.draw(g);
	}
}
